package org.otod.security.service.impl;

import java.util.List;
import java.util.UUID;

import org.otod.security.data.UserMapper;
import org.otod.security.domain.User;
import org.otod.security.service.UserService;
import org.otod.security.web.UserController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
	
	private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

	@Autowired
	private UserMapper userMapper;

	public User getUser(String username) {
		return userMapper.getUserByUsername(username);
	}

	public User getUser(Long id) {
		return userMapper.getUserById(id);
	}
	
	public List<User> getUserList() {
		return userMapper.getUserList();
	}

	public int saveUser(User user) {
		return userMapper.saveUser(user);
	}

	public int inertUser(User user) {
		user.setId(UUID.randomUUID().getMostSignificantBits());
		return userMapper.insertUser(user);
	}

	public int deleteUser(Long id) {
		return userMapper.deleteUser(id);
	}


}
